<?
$gender = array(''=>'--  --','M'=>'male','F'=>'female');
$civil_s = array(''=>'','single'=>'single','married'=>'Married','widowed'=>'widowed','widower'=>'widower');

?>
<div class="row collapse">
	<div class="large-3 small-3 columns">
		<span class="prefix"><strong>Search Employees:</strong></span>
	</div>
	<form action="" method="POST">
	<div class="large-6 small-6 columns">
		<input id="student_enrollment_id" class="searchInput" required autocomplete="off" placeholder="Search Employees." url="<?=site_url('output/ajax_search_employees');?>" type="text" name="student_search_data" autofocus>
		<input type="hidden" value="<?=$hash?>" name="current">
	</div>
	<div class="large-3 small-3 columns">
		<input type="submit" name="search" class="button postfix" value="Search">
	</div>
	</form>
</div>
<?=$system_message;?>
<div class="panel"><strong>Edit Employee</strong></div>
<div class="panel">
<div class="row">
	<div class="large-3 columns">
		<div style="width:180px;height:200px;margin:0 auto;text-align:center;border:2px solid #000;">
			<img style="width:180px;height:196px" src="<?=employee_photo($this->hs->encrypt(intval($emp->emp_id)),$emp->gender);?>">
		</div>
	</div>
	<style>
		.upload input[type="file"]{
		  background: DarkSlateBlue;
		  border:3px solid #231E44;
		  width:30%;
		}
		.upload input[type="submit"]{
		  background: DarkSlateBlue;
		}
	</style>
	<div class="large-9 small-12 columns">
		<p><label class="label label-inverse">Username&nbsp;:</label>&nbsp;<strong><?=$emp->username;?></strong></p>
		<p><label class="label label-inverse">Password&nbsp;:</label>&nbsp;<a href="<?=site_url('employee_settings/change_emp_password/'.$hash);?>"  class='btn btn-mini btn-inverse' id='change_employee_password'>Change Password</a></p>
		<div class="upload">
		<?php echo form_open_multipart('hrd/edit_employee/'.$hash);?>
			<input type="file" name="userfile" size="20" />
			<input id="loading_button" type="submit" name="upload_employee_photo" value="Upload" class="btn btn-primary">
		</form>
		
		</div>
	</div>
</div>
<hr class="clearfix">
<form method="POST" action="<?=site_url('hrd/edit_employee/'.$hash);?>">
<div class="row">
	<label class="label">Personal Information</label>
	<hr class="clearfix">
	<div class="large-4 columns">
		<label>Firstname</label>
		<input type="text" name="fname" value="<?=$emp->first_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Lastname</label>
		<input type="text" name="lname" value="<?=$emp->last_name;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Middlename</label>
		<input type="text" name="mname" value="<?=$emp->middle_name;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Name Ext. i.e(jr,sr,II)</label>
		<input type="text" name="name_ext" value="<?=$emp->name_ext;?>">
	</div>
	<div class="large-4 columns">
		<label>Role</label>
		<input type="text" name="role" value="<?=$emp->role;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Birthdate</label>
		<input type="text" name="dob" value="<?=$emp->birthdate;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Birthplace</label>
		<input type="text" name="pob" value="<?=$emp->birthplace;?>">
	</div>
	<div class="large-4 columns">
		<label>Email Address</label>
		<input type="text" name="email" value="<?=$emp->email;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Gender</label>
		<?=form_dropdown('gender',$gender,set_value('civilstat',$emp->gender));?>
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Civil Status</label>
		<?=form_dropdown('civilstat',$civil_s,set_value('civilstat',$emp->civil_status));?>
	</div>
	<div class="large-4 columns">
		<label>citizenship</label>
		<input type="text" name="citiz" value="<?=$emp->citizenship;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Height</label>
		<input type="text" name="height" value="<?=$emp->height;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Weight</label>
		<input type="text" name="weight" value="<?=$emp->weight;?>">
	</div>
	<div class="large-4 columns">
		<label>Blood Type</label>
		<input type="text" name="bloodt" value="<?=$emp->blood_type;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Religion</label>
		<input type="text" name="religion" value="<?=$emp->blood_type;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>SSS ID:</label>
		<input type="text" name="sss_id"value="<?=$emp->sss_id_no;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Pagibig No.</label>
		<input type="text" name="pagibig" value="<?=$emp->pagibig_no;?>">
	</div>
		<div class="large-4 columns">
		<label>Phil-Health No.</label>
		<input type="text" name="philhealth" value="<?=$emp->philhealth_no;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Residential Tel No:</label>
		<input type="text" name="res_tel" value="<?=$emp->residential_telno;?>">
	</div>
	<div class="large-4 columns">
		<label>Residential Address:</label>
		<input type="text" name="res_addr" value="<?=$emp->residential_address;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Residential Zip:</label>
		<input type="text" name="res_zip" value="<?=$emp->residential_zip;?>">
	</div>
</div>
<div class="row">

	<div class="large-4 columns">
		<label>Permanent Address:</label>
		<input type="text" name="perm_add" value="<?=$emp->permanent_address;?>">
	</div>
		<div class="large-4 columns">
		<label>Permanent Tel No:</label>
		<input type="text" name="perm_tel" value="<?=$emp->permanent_telno;?>">
	</div>
	<div class="large-4 columns">
		<label>Permanent Zip:</label>
		<input type="text" name="perm_zip" value="<?=$emp->permanent_zip;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Church Affiliation:</label>
		<input type="text" name="ch_aff" value="">
	</div>
	<div class="large-4 columns">
		<label>Church Address:</label>
		<input type="text" name="ch_add" value="">
	</div>
	<div class="large-4 columns">
		<label>Church Contact Number:</label>
		<input type="text" name="ch_telno" value="">
	</div>
</div>


<!-- 
 FAMILY BACKGROUND
-->
<div class="row">
	<label class="label">Family Background</label>
	<hr class="clearfix">
</div>
<div class="row">
	<label class="label secondary">Father's Information:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>Father's Firstname</label>
		<input type="text" name="ffname" value="<?=$emp->father_firstname;?>">
	</div>
	<div class="large-4 columns">
		<label>Father's Middlename</label>
		<input type="text" name="fmname"value="<?=$emp->father_middlename;?>">
	</div>
	<div class="large-4 columns">
		<label>Father's Lastname</label>
		<input type="text" name="fsname" value="<?=$emp->father_surname;?>">
	</div>
</div>
<div class="row">
	<label class="label secondary">Mother's Information:</label>
	<br class="clearfix">
	
	<div class="large-4 columns">
		<label>Mother's Firstname</label>
		<input type="text" name="mfname" value="<?=$emp->mother_firstname;?>">
	</div>
	<div class="large-4 columns">
		<label>Mother's Middlename</label>
		<input type="text" name="mmname" value="<?=$emp->mother_middlename;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Mother's Lastname</label>
		<input type="text" name="msname" value="<?=$emp->mother_surname;?>">
	</div>
</div>
<div class="row">
	<label class="label secondary">Spouse's Information:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>Spouse's Firstname</label>
		<input type="text" name="spfname" value="<?=$emp->spouse_firstname;?>">
	</div>
	<div class="large-4 columns">
		<label>Spouse's Middlename</label>
		<input type="text" name="spmname" value="<?=$emp->spouse_middlename;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Spouse's Lastname</label>
		<input type="text" name="ssname" value="<?=$emp->spouse_surname;?>">
	</div>
</div>
<div class="row">
	<div class="large-8 columns">
		<label>Name of Children:</label>
		<textarea></textarea>
	</div>
	<div class="large-4 columns"></div>
</div>

<div class="row">
	<label class="label">Educational Background</label>
	<hr class="clearfix">
</div>
<div class="row">
	<label class="label secondary">ELEMENTARY:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>School Name</label>
		<input type="text" name="elemsname" value="<?=$emp->elem_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Degree/Course:</label>
		<input type="text" name="elemcourse" value="<?=$emp->elem_course;?>">
	</div>
	<div class="large-4 columns">
		<label>Year Graduated (if graduated) :</label>
		<input type="text" name="elemyear" value="<?=$emp->elem_year;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Highest Grade/Level units earned (if not graduate):</label>
		<input type="text" name="elemunits" value="<?=$emp->elem_units;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance From :</label>
		<input type="text" name="elemattfr" value="<?=$emp->elem_attendance_from;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance To :</label>
		<input type="text" name="elemattto" value="<?=$emp->elem_attendance_to;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Scholarship/Academic Honors Recieved </label>
		<input type="text" name="elemhonor" value="<?=$emp->elem_honors_recieved;?>">
	</div>
	<div class="large-9 columns"></div>
</div>

<div class="row">
	<label class="label secondary">Secondary:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>School Name</label>
		<input type="text" name="secname" value="<?=$emp->secondary_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Degree/Course:</label>
		<input type="text" name="seccourse" value="<?=$emp->secondary_course;?>">
	</div>
	<div class="large-4 columns">
		<label>Year Graduated (if graduated) :</label>
		<input type="text" name="secyear" value="<?=$emp->secondary_year;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Highest Grade/Level units earned (if not graduate):</label>
		<input type="text" name="secunit" value="<?=$emp->secondary_units;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance From :</label>
		<input type="text" name="secattfrom" value="<?=$emp->secondary_attendance_from;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance To :</label>
		<input type="text" name="secattto" value="<?=$emp->secondary_attendance_to;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Scholarship/Academic Honors Recieved </label>
		<input type="text" name="sechonors" value="<?=$emp->secondary_honors_recieved;?>">
	</div>
	<div class="large-9 columns"></div>
</div>

<div class="row">
	<label class="label secondary">College:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>School Name</label>
		<input type="text" name="colname" value="<?=$emp->college_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Degree/Course:</label>
		<input type="text" name="colcourse" value="<?=$emp->college_course;?>">
	</div>
	<div class="large-4 columns">
		<label>Year Graduated (if graduated) :</label>
		<input type="text" name="colyear" value="<?=$emp->college_year;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Highest Grade/Level units earned (if not graduate):</label>
		<input type="text" name="colunits" value="<?=$emp->college_units;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance From :</label>
		<input type="text" name="colattfrom" value="<?=$emp->college_attendance_from;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance To :</label>
		<input type="text" name="colattto" value="<?=$emp->college_attendance_to;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Scholarship/Academic Honors Recieved </label>
		<input type="text"  name="colhonors" value="<?=$emp->college_honors_recieved;?>">
	</div>
	<div class="large-9 columns"></div>
</div>

<div class="row">
	<label class="label secondary">Vocational:</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>School Name</label>
		<input type="text" name="vocname" value="<?=$emp->voc_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Degree/Course:</label>
		<input type="text" name="voccourse" value="<?=$emp->voc_course;?>">
	</div>
	<div class="large-4 columns">
		<label>Year Graduated (if graduated) :</label>
		<input type="text" name="vocyear" value="<?=$emp->voc_year;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Highest Grade/Level units earned (if not graduate):</label>
		<input type="text" name="vocunits" value="<?=$emp->voc_units;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance From :</label>
		<input type="text" name="vocattfrm" value="<?=$emp->voc_attendance_from;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance To :</label>
		<input type="text" name="vocattto" value="<?=$emp->voc_attendance_to;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Scholarship/Academic Honors Recieved </label>
		<input type="text" name="vochonors" value="<?=$emp->voc_honors_recieved;?>">
	</div>
	<div class="large-9 columns"></div>
</div>


<div class="row">
	<label class="label secondary">GRADUATE/MASTERAL :</label>
	<br class="clearfix">
	<div class="large-4 columns">
		<label>Name Of School</label>
		<input type="text" name="gradname" value="<?=$emp->grad_name;?>">
	</div>
	<div class="large-4 columns">
		<label>Degree/Course</label>
		<input type="text" name="gradcourse" value="<?=$emp->grad_course;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Year Graduated (If Graduated):</label>
		<input type="text" name="gradyear" value="<?=$emp->grad_year;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Highest Grade/Level units earned (if not graduate) :</label>
		<input type="text" name="gradunits" value="<?=$emp->grad_units;?>">
	</div>
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance From :</label>
		<input type="text" name="gradattfrm" value="<?=$emp->grad_attendance_from;?>">
	</div>
	
	<div class="large-4 columns">
		<label>Inclusive Date of Attendance To :</label>
		<input type="text" name="gradattto" value="<?=$emp->grad_attendance_to;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label>Scholarship/Academic Honors Recieved :</label>
		<input type="text" name="gradhonors" value="<?=$emp->grad_honors_recieved;?>">
	</div>
	<div class="large-9 columns"></div>
</div>
<div class="row">
	<div class="large-8 columns">
		<label>Other Things you want us to know:</label>
		<textarea></textarea>
	</div>
	<div class="large-4 columns"></div>
</div>
<div class="row">
	<div class="large-8 columns">
		<input type="hidden" value="s1_sds_doc" value="<?=substr(md5(mt_rand(10,1234)),3,14);?>"/>
		<input type="hidden" value="spr_a_loc" value="<?=mt_rand(1234,3234);?>"/>
		<input type="submit" class="btn btn-primary" name="edit_employee" value="Edit Employee Profile">
		</form>
	</div>
	<div class="large-4 columns"></div>
</div>
</div>
<script type="text/javascript" src="<?=script_url('custom/fsearch_2');?>"></script>
<script>
	$(document).ready(function(){
		$('a#change_employee_password').on('click',function(e){
			e.preventDefault();
			

			$( "#msgDialog" ).on( "dialogbeforeclose", function( event, ui ) {
            	$("#msgDialog > div.content").empty();
        	} );
			// var new_div = document.createElement("div");
			// new_div.id = 'msgDialog';

			var url = $(this).attr('href');

	        $("#msgDialog").dialog('option','width',400);
	        $("#msgDialog").dialog('option','height',500);
			$("#msgDialog").dialog('option','title','Change Password.');
	        $("#msgDialog").dialog('option', 'buttons', {
	        "Cancel" : function() {
					$(this).dialog("close");
	            }
	        });

	        var form = '';
	        	form += '<form id="delete_student_form" action="'+ url +'" method="post" autocomplete="off">';
	        	form += '<span class="small-info">Password and Confirm Password must be the same, minimum of 4 characters alphanumeric, spaces will be automatically removed.</span><hr class="clearfix">';
	        	form += '<label>Password</label><input id="password" type="text" name="pass" placeholder="Password" title="User Password" required>';
	        	form += '<label>Confirm Password</label><input id="user_password" type="text" name="c_pass" placeholder="Confirm Password" title="Confirm User Password" required>';
	        	form += '<br>';
	        	form += '<input type="submit" name="delete" value="Process Change Password" class="btn btn-danger">';
	        	form += '</form>';
	        $("#msgDialog > div.content").html(form);
	        $("#msgDialog").dialog("open");

		});


		$(document).on('submit','form#delete_student_form',function(e){
		        	e.preventDefault();

		        	var password = $(this).find('#password').val();
		        	var c_password = $(this).find('#user_password').val();
		        	var url = $(this).attr('action');

		        	if(password == c_password && password.length >=4 && c_password.length >=4 )
		        	{
		        	$.ajax({
		        		method:'POST',
		        		url:url,
		        		data:$(this).serialize()
		        	}).done(function(e){
		        		if(e == 1)
		        		{
		                 alert('Password successfully changed.');
		        		}else if(e == 2)
		        		{
		                 alert('Unable to change employee password.');
		        		}else if(e == 0){
		        			
		        		}

		        	}).fail(function(){
		                  alert('error Occured changing of password failed, unable to establish connection with server.');
		        	}).always(function(){
		                $('#msgDialog').dialog("close");
		            });

		        	}else{
						alert('Password and Confirm password must be the same, minimum of 4 characters.'); 
		        	}
		        });
	});
</script>